#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
vector<int> searchRange(vector<int>& nums, int target) {
    vector<int>ans;
    int left = 0;int right = nums.size() - 1;int tmp = -1;
    while (left <= right)
    {
        int mid = left + (right - left) / 2;
        if (nums[mid] > target)right = mid - 1;
        else if (nums[mid] < target)left = mid + 1;
        else { tmp = mid;break; }
    }
    int ttmp = tmp;
    if (ttmp == -1)return { -1,-1 };
    while (left <= ttmp)
    {
        int mid = left + (ttmp - left) / 2;
        if (nums[mid] != target)left = mid + 1;//
        else ttmp = mid-1;
    }
    ans.push_back(ttmp+1);
    ttmp = tmp;
    while (ttmp <= right)
    {
        int mid = ttmp + (right - ttmp) / 2;
        if (nums[mid] != target)right = mid - 1;
        else ttmp = mid+1;
    }
    ans.push_back(ttmp-1);
    return ans;
}
int main()
{
    vector<int>v = { 5,7,7,8,8,10 };
    searchRange(v, 6);
    return 0;
}